package com.bkhech.home.practice.spring.factorybean;

import org.springframework.beans.factory.FactoryBean;

/**
 * 自定义 FactoryBean
 *
 * @author guowm
 * @date 2023/1/29
 */
public class BeanAFactoryBean implements FactoryBean<BeanA> {
    @Override
    public BeanA getObject() throws Exception {
        // TODO 可以写复杂的初始化逻辑
        System.out.println("可以写复杂的初始化 BeanA 逻辑");
        return new BeanA("factory bean");
    }

    @Override
    public Class<?> getObjectType() {
        return BeanA.class;
    }


    /**
     * Default is true
     *
     * @return
     */
    @Override
    public boolean isSingleton() {
        return FactoryBean.super.isSingleton();
    }
}
